<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/detail/default.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/detail/component.css" />
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/amazeui.min.css"/>
		<link rel="stylesheet" type="text/css" href="{$_C.hy_path}css/hy.admin.css"/>
		<script src="{$_C.hy_path}js/detail/modernizr.custom.js"></script>
		
	</head>
	<body>
		<div class="am-g">
			 {include file='../Common/hy_header.html'}
			 	
      <div class="am-u-md-6 am-cf">
        <div class="am-fl am-cf">
          <div class="am-btn-toolbar am-fl">
             <div class="am-btn-group am-btn-group-xs">
            
            <button data-title="新建抽奖信息" data-id="add_luckyDraw" data-href="index.php?g=admin&m=chat&a=add_luckyDraw" class="am-btn am-btn-default am-btn-xs am-text-secondary hy-js-href"><span class="am-icon-plus"></span> 新建抽奖信息</button>
		   
		    </div>
           
          </div>
        </div>
      </div>
      <div class="am-u-md-3 am-cf">
        <div class="am-fr">
        </div>
      </div>
      
      <div class="am-g">
      <div class="am-u-sm-12">
        <div class="am-form">
          <table class="am-table am-table-striped am-table-hover hy-table-main">
            <thead>
              <tr>
                <th class="table-title">序号</th>
                <th class="table-type">抽奖名称</th>
                <th class="table-type">抽奖状态</th>
                <th class="table-type">红包数量</th>
                <th class="table-date">有效时间</th>
                <th class="table-date">状态</th>
                <th class="table-set">操作</th>
              </tr>
          </thead>
          <tbody>
          	{foreach from=$luckyDraw_list item=ad}
            <tr>
              <td>{$ad.id}</td>
              <td>{$ad.title}</td>
              <td>{$ad.onoffShow}</td>
              <td>{$ad.total}</td>
              <td>{$ad.begin_time|date_format:'Y-m-d H:i:s'} - {$ad.expire_time|date_format:'Y-m-d H:i:s'}</td>
              <td>{$ad.statusShow}</td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                    <button data-title="{$ad.title}" data-id="hongbao_{$ad.id}" data-href="index.php?g=admin&m=chat&a=hongbao&id={$ad.id}" class="am-btn am-btn-default am-btn-xs am-text-secondary hy-js-href"><span class="am-icon-pencil-square-o"></span> 内置红包</button>
	              	{if $ad.status eq 2}
                    <button data-title="{$ad.title}" data-id="addlucky_{$ad.id}" data-href="index.php?g=admin&m=chat&a=add_luckyDraw&id={$ad.id}" class="am-btn am-btn-default am-btn-xs am-text-secondary hy-js-href"><span class="am-icon-pencil-square-o"></span> 编辑</button>
                    <button onClick="entering({$ad.id})" data-href="index.php?g=admin&m=chat&a=entering_hongbao&id={$ad.id}" class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 正式启用</button>
					{else}
                    <button data-title="{$ad.title}--领取信息" data-id="draw_{$ad.id}" data-href="index.php?g=admin&m=chat&a=draw&id={$ad.id}" class="am-btn am-btn-default am-btn-xs am-text-secondary hy-js-href"><span class="am-icon-pencil-square-o"></span> 领取信息</button>
					{if $ad.onoff eq 1}
                    <button onClick="closeHongbao({$ad.id})"  class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 设为关闭</button>
					{else}
                    <button onClick="closeHongbao({$ad.id})"  class="am-btn am-btn-default am-btn-xs am-text-secondary"><span class="am-icon-pencil-square-o"></span> 重新开启</button>
					{/if}
					{/if}
					
                  </div>
                </div>
              </td>
            </tr>
             {/foreach} 
          </tbody>
        </table>
          <div class="am-cf">

  <div class="am-fr">
  	<div class="hy_page">
  {$luckyDraw_list_page}
  </div>
  </div>
</div>
          <hr />
      
        </div>
      </div>

    </div>
    </div>
	
   {include file='../Common/hy_footer.html'}
<script type="text/javascript">
  	function entering(id){
		var data = {
					"id":id
				};
		var url ="index.php?g=admin&m=chat&a=entering_lucky";
		$.post(url,data,function(result){
			if (result.error == 0) {
				alert(result.content);
				window.location.href="index.php?g=admin&m=chat&a=luckyDraw";
			}else{
				showMsg(result.content,result.error);
			}
		},"json");
	}
		
	function listHongbao(lottery_id){
		var data = {
					"id":lottery_id
				};
		var url ="index.php?g=admin&m=chat&a=listHongbao";
		$.post(url,data,function(result){
			console.info(result);
		},"json");
	}
	function closeHongbao(lottery_id){
		var data = {
					"id":lottery_id
				};
		var url ="index.php?g=admin&m=chat&a=closeHongbao";
		$.post(url,data,function(result){
			if (result.errcode == 0) {
				alert("操作成功");
				window.location.href="index.php?g=admin&m=chat&a=luckyDraw";
			}else{
				showMsg(result.errmsg,1);
			}
		},"json");
	}
  	</script>  
		
	</body>
</html>
